package _interview75;

import _object.ListNode;

import java.util.ArrayList;

/**
 * 2130. 链表最大孪生和
 */
public class No2130 {
    public int pairSum(ListNode head) {
        ListNode slow = head, fast = head;
        ArrayList<Integer> list = new ArrayList<>();
        int index = 0;
        while (fast != null && fast.next != null) {
            list.add(index++, slow.val);
            slow = slow.next;
            fast = fast.next.next;
        }
        int answer = 0;
        while (slow != null) {
            answer = Math.max(list.get(--index) + slow.val, answer);
            slow = slow.next;
        }
        return answer;
    }
}
